<%--
  Created by IntelliJ IDEA.
  User: 肖遥
  Date: 2020/6/29
  Time: 11:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

    <div>
        申报状态：
        <select id="status">
            <option value="-1">全部</option>
            <option value="0">已申报</option>
            <option value="1">审核中</option>
            <option value="2">已审核</option>
        </select>
        <input type="button" value="查询" id="btn">
    </div>
    <h1>申报项目列表</h1>
    <table>
        <c:if test="${requestScope.flag==1}">审核成功</c:if>
        <c:if test="${requestScope.flag==0}">审核失败</c:if>
        <tr>
            <td>项目标号</td>
            <td>项目名称</td>
            <td>申报开始日期</td>
            <td>申报结束日期</td>
            <td>申报状态</td>
            <td>操作</td>
        </tr>
    </table>
    <script src="js/jquery-1.8.3.js"></script>
    <script>
    $(function(){
        bindDate()
        bindEvent()
    })

    function bindDate(){
        $.post("listProjectInfo",function(msg){
            var str="";
            $(msg).each(function(i){
                var p=msg[i];
                 str += "<tr>"
                 str+="<td>"+p.id+"</td>"
                str+="<td>"+p.projectName+"</td>"
                str+="<td>"+p.startDate+"</td>"
                str+="<td>"+p.endDate+"</td>"
                if(p.status==0){
                    str+="<td>已申报</td>"
                }else if(p.status==1){
                    str+="<td>审核中</td>"
                }else{
                    str+="<td>已审核</td>"
                }
                if(p.status!=2){
                    str+="<td><a href='findById?id="+p.id+"'>审核</a></td>"
                }else {
                    str+="<td> </td>"
                }
                 str+="</tr>"
            })
            $("table").append(str);
        },"json")
    }

        function bindEvent(){
            $("#btn").click(function(){
                var status=$("#status").val();
                $.post("searchProjectInfo",{"status":status},function(msg){
                    var str="";
                    $(msg).each(function(i){
                        var p=msg[i];
                        str += "<tr>"
                        str+="<td>"+p.id+"</td>"
                        str+="<td>"+p.projectName+"</td>"
                        str+="<td>"+p.startDate+"</td>"
                        str+="<td>"+p.endDate+"</td>"
                        if(p.status==0){
                            str+="<td>已申报</td>"
                        }else if(p.status==1){
                            str+="<td>审核中</td>"
                        }else{
                            str+="<td>已审核</td>"
                        }
                        if(p.status!=2){
                            str+="<td><a href='findById?id="+p.id+"'>审核</a></td>"
                        }else {
                            str+="<td> </td>"
                        }
                        str+="</tr>"
                    })
                    $("table tr:not(:first)").remove();
                    $("table").append(str);
            },"json")
            })
    }

    </script>
</body>
</html>
